package com.example.active.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.messaging.Message;

import javax.jms.Queue;
import javax.jms.TextMessage;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/9/18 14:05
 */
//@Component
public class QueueConsumerBoot
{
    @Autowired
    JmsMessagingTemplate jmsMessagingTemplate;
    @Autowired
    Queue queue;

    @JmsListener(destination = "${myqueue}")
    public void receive()
    {
        Message<TextMessage> message = (Message<TextMessage>) jmsMessagingTemplate.receive(queue);
        System.out.println("QueueConsumerBoot--->"+message.getPayload());
    }
}
